package com.cke.yang.security.api.controller;

import com.cke.yang.common.domain.model.Result;
import com.cke.yang.security.api.dto.response.SecMenuNodeResponse;
import com.cke.yang.security.app.service.SecMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 菜单控制器
 *
 * @author yuyang
 */
@RestController
@RequestMapping("/api/security/sec-menu")
public class SecMenuController {

    @Autowired
    private SecMenuService secMenuService;

    /**
     * 获取当前用户的当前角色的菜单列表
     *
     * @return 当前用户当前角色的菜单列表
     */
    @GetMapping("/self")
    public Result<List<SecMenuNodeResponse> > getCurrentRoleMenus() {
        List<SecMenuNodeResponse> menus = secMenuService.getCurrentRoleMenus();
        return Result.success(menus);
    }

}

